package com.mega.fe.god;

import com.mega.fe.fuck.FuckEntityRenderDispatcher;
import com.mega.fe.util.MEGA;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.ItemInHandRenderer;
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraft.server.packs.resources.ResourceManager;

public class GodGameRenderer extends GameRenderer {
    public GodGameRenderer(Minecraft p_234219_, ItemInHandRenderer p_234220_, ResourceManager p_234221_, RenderBuffers p_234222_) {
        super(p_234219_, p_234220_, p_234221_, p_234222_);
    }

    @Override
    public void render(float p_109094_, long p_109095_, boolean p_109096_) {
        Minecraft mc = getMinecraft();
        if (mc.screen != null)    {
            if (mc.screen instanceof TitleScreen && !(mc.screen instanceof FantasyTitleScreen)) {
                mc.screen = new FantasyTitleScreen();
                mc.screen.init(mc, mc.window.getGuiScaledWidth(), mc.window.getGuiScaledHeight());
                ((FantasyTitleScreen) mc.screen).millisStart = System.currentTimeMillis();
            }
        }
        try {
            if (MEGA.KLASS_PTR(mc.entityRenderDispatcher) != FuckEntityRenderDispatcher.klass_ptr)
                MEGA.replaceClass(mc.entityRenderDispatcher, FuckEntityRenderDispatcher.class);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        super.render(p_109094_, p_109095_, p_109096_);
    }
}
